package com.ruoyi;

import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.project.business.controlcenter.iot.util.IpUtil;
import com.ruoyi.project.business.nativedevice.service.INativeDeviceService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

/**
 * 启动程序
 *
 * @author thanks
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@MapperScan("com.ruoyi.project.*.*.mapper")
public class MainApplication implements CommandLineRunner {
    @Autowired
    private INativeDeviceService nativeDeviceService;

    public static void main(String[] args) {
        SpringApplication.run(MainApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  启动成功，Thanks for RuoYi   ლ(´ڡ`ლ)ﾞ ");
    }


    @Override
    public void run(String... args) throws Exception {
        String ip = IpUtils.getHostIp();
        String mac = "SERVER-001";
        String deviceCode = "SERVER-001";
        nativeDeviceService.saveOrUpdateDevice(ip, mac, deviceCode);
    }
}
